# import requests
#
# from api.api_test_login import TestLogin
# from common.DBUtil import DBUtil
#
#
# class TestAdd(object):
#     def test_add(self):
#         # print(TestLogin.test_login().get("data"))
#         url = "http://ihrm-test.itheima.net/api/sys/user"
#         login_add = TestLogin.test_login()
#         token = "Bearer " + login_add.get("data")
#         headers = {"Content-Type": "application/json","Authorization":token}
#         body = {"username": "DB01","mobile": "17591081111","workNumber": "123"}
#         # sql = "insert into "
#         # DBUtil.uid_db(sql)
#         resp_add = requests.post(url,headers=headers,json = body)
#         print(resp_add.json())
#         # login_add = TestLogin.test_login()
#
#         # print(resp_add.json())
# if __name__ == '__main__':
#     add = TestAdd()
#     add.test_add()
import requests

from api.api_test_login import TestLogin
from common.DBUtil import DBUtil

resp = TestLogin.test_login()
token = "Bearer " + resp.json().get("data")
print(token)
sql = "delete from bs_user where mobile='17591081681';"
DBUtil.uid_db(sql)
url_add = "http://ihrm-test.itheima.net/api/sys/user"

headers = {"Content-Type": "application/json", "Authorization": token}
body_add = {"username": "DB01", "mobile": "17591081681", "workNumber": "123"}
resp_add = requests.post(url_add, headers=headers, json=body_add)
print(resp_add.json())

id = resp_add.json().get("data").get("id")
url_query = "http://ihrm-test.itheima.net/api/sys/user" + "/" + id
re = requests.get(url= url_query,headers=headers)
print(re.json())